﻿using DevExpress.XtraEditors;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.抖音出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.抖音出入库.抖音下单
{
    public partial class Form秒杀商品 : DevExpress.XtraEditors.XtraForm
    {
        private List<RetailSkuDTO> retailSkuDTOs;
        public Form秒杀商品()
        {
            InitializeComponent();
            this.refresh();
        }

        private void refresh()
        {
            this.retailSkuDTOs = 零售Service.getUnDeliveryOrder("SSHIRT", "18");
            this.gridControl零售.DataSource = this.retailSkuDTOs;
            this.gridView零售.RefreshData();
        }

        private void 秒杀下单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                String skuId = this.gridView零售.GetRowCellValue(this.gridView零售.FocusedRowHandle, "skuId").ToString();
                foreach (RetailSkuDTO item in this.retailSkuDTOs)
                {
                    if (skuId.Equals(item.skuId))
                    {
                        new Form秒杀下单(item).ShowDialog();
                        break;
                    }
                }
            }
            catch { }
        }

        private void gridView零售_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            try
            {
                String pictureUrl = this.gridView零售.GetRowCellValue(this.gridView零售.FocusedRowHandle, "pictureUrl").ToString();
                //显示图片
                this.pictureBox商品图片.LoadAsync(URL.图片url + URL.零售秒杀商品图片 + pictureUrl);
            }
            catch { }
        }

        private void simpleButton新增商品_Click(object sender, EventArgs e)
        {
            new Form秒杀创建款式().ShowDialog();
        }
    }
}